import Vue from 'vue'
import VueI18n from 'vue-i18n'
import { getStorage } from '@/utils'
// 导入element-ui语言包
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import twLocale from 'element-ui/lib/locale/lang/zh-TW'
// 导入自定义语言包
import zhCustom from './lib/zh'
import enCustom from './lib/en'
import twCustom from './lib/tw'
Vue.use(VueI18n)

// 创建语言实力对象
const i18n = new VueI18n({
  locale: getStorage('lang') || 'zh', // 默认初始语言环境
  messages: {
    zh: {
      ...zhLocale, ...zhCustom
    },
    en: {
      ...enLocale, ...enCustom
    },
    tw: {
      ...twLocale, ...twCustom
    }
  }
})
// 暴露
export default i18n
